to_bytes_unsigned
Convert this non-negative big_integer
to a byte array, with no sign bit.
The generated byte array has more significant bits on the left and less significant bits on the right (big-endian).
Inverse of big_integer.from_bytes_unsigned()
.
When this big_integer
is equal to 0
, the empty byte array x''
is returned (this is consistent with the inverse function big_integer.from_bytes_unsigned()
, which interprets x''
as 0
).
Examples:
0L.to_bytes_unsigned()
returnsx''
(-1L).to_bytes_unsigned()
throws an exception1L.to_bytes_unsigned()
returnsx'01'
2L.pow(100).to_bytes_unsigned()
returnsx'10000000000000000000000000'
Since
0.12.0
Throws
exception
if this big_integer
is negative